/*
 * Copyright 2011 Mark Davidson.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.dctmcommons;

/**
 * Helper methods for validating parameters.
 * @author Mark Davidson
 */
public interface IParamCheck {

	/**
	 * Checks if the object is null. If so, an {@link NullParameterException}
	 * is thrown. This allows us to perform simple assert-like parameter checks
	 * without having to enable the '-ea' JVM switch.
	 * @param value The parameter value
	 * @param name The parameter name
	 * @throws NullParameterException Thrown if the object is null
	 */
	public void checkObject(final Object value) throws NullParameterException;
	
	/**
	 * Checks if the object is null. If so, an {@link NullParameterException}
	 * is thrown. This allows us to perform simple assert-like parameter checks
	 * without having to enable the '-ea' JVM switch.
	 * @param value The parameter value
	 * @param name The parameter name
	 * @throws NullParameterException Thrown if the object is null
	 */
	public void checkObject(final Object value, final String name)
		throws NullParameterException;
	
	/**
	 * Checks if the string value is null or zero length (after trimming it). If
	 * so, an {@link EmptyStringParameterException} is thrown. This allows us
	 * to perform simple assert-like parameter checks without having to enable
	 * the '-ea' JVM switch.
	 * @param value The parameter value
	 * @throws EmptyStringParameterException Thrown if the string value is empty
	 */
	public void checkString(final String value)
		throws EmptyStringParameterException;
	
	/**
	 * Checks if the string value is null or zero length (after trimming it). If
	 * so, an {@link EmptyStringParameterException} is thrown. This allows us
	 * to perform simple assert-like parameter checks without having to enable
	 * the '-ea' JVM switch.
	 * @param value The parameter value
	 * @param name The parameter name
	 * @throws EmptyStringParameterException Thrown if the string value is empty
	 */
	public void checkString(final String value, final String name)
		throws EmptyStringParameterException;
}
